<?php
/**
 * <https://y.st./>
 * Copyright © 2019 Alex Yst <mailto:copyright@y.st>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org./licenses/>.
**/

$xhtml = array(
	'<{title}>' => 'Hacking <code>param2</code>',
	'takedown' => '2017-11-01',
	'<{body}>' => <<<END
<img src="/img/CC_BY-SA_4.0/y.st./weblog/2019/05/21.jpg" alt="Purple flowers" class="framed-centred-image" width="800" height="480"/>
<section id="diet">
	<h2>Dietary intake</h2>
	<p>
		I dreamed I had big, white, bird wings on my back. I&apos;d flown several kilometres to another city.
		From there, I&apos;d flown to a neighbouring city, made a right angle, and flown to third city.
		My quest?
		I was looking for pizza.
	</p>
	<p>
		I stopped in ... I don&apos;t quite remember what it was.
		It might have been a bank, or some sort of office building.
		In any case, I asked for directions there.
		I&apos;m not sure why, but the person instead told me about these paper-sorting bins that could be folded up when not in use.
		They brought me to someone that had one, and they were like three fold-up laundry hampers, but built into one item, thinner than a hamper would need to be for structural support when full of heavy clothing.
		It was red, and had a graphic on them that made it look like the bins were to be used to store papers you didn&apos;t want.
		It might have been a trash can with papers falling down into it, but I don&apos;t recal.
		Suddenly, I had one, only mine was better.
		Mine was yellow, but what made mine better was that it didn&apos;t have a graphic that made me thing this was some sort of recycling can.
		Instead, it had mock warning triangles.
	</p>
	<p>
		I said I&apos;d try back at the first city, and regardless of success or failure, I&apos;d have to get home.
		When I&apos;d tried there earlier, the pizza place wasn&apos;t open, but maybe they would be now.
		The second person I&apos;d spoken with, the one with the paperwork bins, said to let them know and let the first person I&apos;d spoken with know how it went.
		I asked how I was to do that.
		I thought about the fact that I had literally zero contact information for these people.
		Being me, I assumed they wanted a telephone call, but even if I&apos;d had a telephone, which I knew I didn&apos;t, they&apos;d never given me their telephone numbers.
		It turns out they wanted me to <strong>*come back*</strong> to tell them!
		I extended my wings to show them, explained that I was travelling by flight, an that it was a long way back just to let them know if I&apos;d found pizza.
		I&apos;d have to fly to the next city over from where we were, make a right angle, and fly to the next city from there.
		(Why couldn&apos;t I fly directly to the second city over and save flying time and effort?
		I&apos;m not sure, actually.)
		And from there, I&apos;d need to fly even further to get home.
		I&apos;d already spent all day on an errand I didn&apos;t think would take so long, and I needed to get home and rest.
		Coming back wasn&apos;t really an option.
	</p>
	<p>
		We went out of the building together.
		I&apos;m not exactly sure why.
		As we were in a group though, I couldn&apos;t fly, as the other two people obviously couldn&apos;t get airborne, so we walked.
		It seems night had fallen.
		We walked past a building that I think was some sort of moon museum, but it was pretty strange.
		The building and the sidewalk around it were painted up with pixilated moon craters.
		I didn&apos;t really get it, but the place was closed, and even if it was open, I was in a group now and couldn&apos;t make detours to ask silly questions to fulfil idle curiosities.
		The sidewalk for some reason was uneven, and I had to make a conscious effort not to fall off of it at one spot.
		Of course, that spot had two or three people in lawn chairs taking up the only part of that stretch that would have been easy to walk on.
	</p>
	<p>
		I woke up before my party made it anywhere.
		I&apos;m not sure where we were going though.
		I don&apos;t think we were walking two cities over to get the pizza, and if were were, travel on foot would have taken too long and the place would be closed again, if it&apos;d opened to begin with.
		On foot, we couldn&apos;t optimise and skip the middle city, either, though from the sound of how I was talking, I wasn;t going to do that when travelling by air anyway.
	</p>
</section>
<section id="Minetest">
	<h2>Minetest</h2>
	<p>
		I think the key to making every node infusible with elements is to find some passive effect infused nodes can have on elemental nodes that actually have an effect.
		This will give a purpose to infusing nodes with elements without requiring twenty-six unique effects for each node.
		Even if I had enough creativity to come up with the thousands of effects that&apos;d entail, it&apos;d take over the game too much.
		I want definitely useful effects, but at the same time, I want the system ignorable by players that aren&apos;t interested and just want to play the base subgame.
	</p>
	<p>
		One thing has really been bothering me when it comes to programming my bed nodes.
		Beds can only be rotated in four directions.
		You can&apos;t flip them upside-down or sideways.
		This means they only use four of their twenty-four allotted <code>param2</code> values per colour.
		The Minetest engine already practically throws away huge chunks of the palette space, and this makes it so much worse.
		The obvious solution is to set <code>paramtype2</code> to <code>colorwallmounted</code> instead of <code>colorfacedir</code>.
		This limits each bed colour to six facings instead of twenty-four, then the engine throws away two would-be-usable indexes.
		This means each bed colour practically takes up eight indexes, four of which would actually get used, bringing the number of bed colours up to thirty-two, instead of sixteen.
		It doubles what we can do.
		However, when I tried to set this up in the past, just assuming it would work, I kept getting my texture directions wrong until I finally figured out another problem I had to deal with: when using the <code>wallmounted</code> and <code>colorwallmounted</code> settings of <code>paramtype2</code>, Minetest doesn&apos;t rotate textures, it only rotates the shapes of the nodes.
		You have to use the <code>colorfacedir</code> setting instead, and waste nearly all of your palette indexes on facings you&apos;ll never use.
		The exception, it seemed at the time, was meshes.
		Torches use meshes, and their textures rotate just fine.
		It&apos;s only an issue when using node boxes.
		However, I&apos;ve asked the Minetest community for help figuring out how to build meshes before, and had no one actually help me.
		I wasn&apos;t sure how I could possibly get a mesh working.
		One thing was for sure though: if I wanted proper support for beds and other similar nodes, figuring out how to build meshes was an absolute requirement.
	</p>
	<p>
		I&apos;ve sat down with Blender and tried to figure this out on my own in the past.
		Today, I tried again.
		If I didn&apos;t have the kinks worked out <strong>*before*</strong> my first release, it&apos;d be too late, as the indexes would already be assigned, and they&apos;d be cemented by the fact that changing them would break maps that had used the older version of my mods, then upgraded to a new version.
		This time though, I was just trying to build a cube.
		I wasn&apos;t even aiming for getting a bed model functioning.
		I just wanted a cube.
		I managed to get a cube of a very wrong size made, and it wasn&apos;t handling textures properly whatsoever.
		Eventually, I figured out how to resize the cube, but found that a cube size of one unit was too small in Minetest.
		I&apos;m still not sure what the deal with that is.
		Through trial and error, I&apos;ve found that a cube side length of 1.028 units in Blender seems to be the perfect size to be a regular node in Minetest.
		Why that measurement?
		I have absolutely no idea.
		With that finally done, I tried to no avail to get the texture issue fixed.
		I looked up a few tutorials, only the last of which was able to actually explain how to fix the issue.
		I think I can get a rectangular prism of whatever dimensions I want to work now, though the so-called &quot;fancy beds&quot; might be another headache to deal with when I get to them.
	</p>
	<p>
		Oh, and by the way, when I tested my regular cube out, the textures rotated correctly with the <code>paramtype2</code> set to <code>wallmounted</code>.
		This is totally going to work.
		It&apos;s probably harder on the rendering engine than if Minetest just allowed textures to be rotated properly with <code>wallmounted</code> nodes, even if they were just of the <code>normal</code> <code>drawtype</code>.
		I think with meshes, all sides get drawn, while with <code>normal</code> nodes, only the sides visible to the player get drawn.
		I&apos;m not sure there&apos;s any significant different between how meshes are drawn and how node boxes are drawn, but this cube mesh is for basically hacking in support for <code>wallmounted</code> regular nodes.
	</p>
	<p>
		With this new mesh, I should be able to have chests support all current elements.
		In exchange, you just won&apos;t be able to flip chests upside down or most sideways directions.
		When I apply my new knowledge to making the bed mesh, it&apos;ll allow me to make beds support all current elements too, but with absolutely no downsides.
		I figured I could apply this to other nodes too, if they didn&apos;t actually need upside-down and sideways facings.
		I&apos;d look into that later.
	</p>
	<p>
		Before getting to that, I contemplated how to squeeze more elements into other types of nodes.
		First, stairs.
		Stairs typically have the usual twenty-four facing directions, but half of those are, from a strictly shape-based approach, duplicates of the other half.
		That means I can cut each stair element&apos;s available indexes in half to use the other half for another element.
		The catch is that half the supported elements will produce stairs with sideways textures.
		I think that will actually add variety for the most part, though the problem comes when advanced builders want to use a screwdriver to flip the nodes and their textures.
		They won&apos;t be able to do it like they can with regular stairs.
		Still, I think it&apos;s a good trade-off.
		Using the space the engine typically throws away, I can fit in partial support for eight more elements on top of that, though not whole support because the engine doesn&apos;t modulo the <code>param2</code> value to find the rotation at the correct spot.
		Slabs can be converted to <code>colorwallmounted</code> with practically no ill effects.
		You can&apos;t flit the textures around, just like the stairs, but you really don&apos;t need to.
	</p>
	<p>
		Logs were the next thing I thought about.
		Rotating them around their primary axis causes a nearly imperceivable change in what they look like.
		That means we can cut the space they use in four.
		But that axis can also be entirely flipped around for another nearly imperceivable change, cutting their space in half.
		It introduces absolutely zero quirks to do this, and it actually removes a minor quirk I&apos;ve not liked in the default logs.
		Furthermore, if we rotate the textures around a bit, we can take the index space that would have been throw away by the engine, which we could easily craft into partial support for eight more log types, and instead get full support for <strong>*sixteen*</strong> more elemental logs, plus sixteen completely unrotatable log types left over.
		That&apos;s eighty fully-supported log elements, with sixteen extra logs left over if the element space ever grows beyond eighty, which it probably won&apos;t.
	</p>
	<p>
		Using similar logic as with logs, I managed to multiply full brick block support by four.
		Mild quirks will be present when using different types of elemental bricks next to one another, but it&apos;ll be acceptable.
		By rotating the textures as I&apos;ll do with the logs, I can squeeze in eight more supported brick elements, bringing the total to forty.
		That&apos;s more than adequate for the foreseeable future.
		There will also be left over space for eight elemental bricks that can&apos;t be rotated.
	</p>
	<p>
		With those basic classes of nodes solved for, I started going through the list of nodes with only partial support to see what I could apply my ideas to.
		First, I encountered bookshelves.
		I couldn&apos;t treat them like logs or bricks.
		The textures get flipped upside-down for half the elements, which would make the books float to the top of the shelf instead of resting at the bottom.
		I figured that was a loss and moved on.
		I quickly came back to bookshelves though.
		The books shouldn&apos;t float to the top, which means the bookshelves shouldn&apos;t be upside-down.
		I can just make them <code>colorwallmounted</code>.
		They won&apos;t be able to take on all sideways positions, but really, they shouldn&apos;t take on <strong>*any*</strong> sideways positions.
		Not with those textures.
		When I came to the vessels shelf, the same logic applied to that node as well.
	</p>
	<p>
		Cacti can act like logs.
		Cacti support just got bumped up to eighty.
		Wooden slats can act like bricks.
		Slat support just got bumped up to forty.
	</p>
	<p>
		I had to experiment with doors a bit to see what positions they could take.
		I assumed they&apos;d be in the same position as beds.
		When I went to use a screwdriver on one to test though, I found that doors are programmed to not be rotatable at all.
		What in Squiddy&apos;s name?
		Whatever.
		Bed&apos;s use custom screwdriver logic to prevent bizarre bed positions.
		Doors don&apos;t end up in bizarre positions because there&apos;s no way to rotate them and placing nodes with a facing will cause them to take one of only four facings by default.
		The reasoning is different between these two, but the end result is the same: <code>colorwallmounted</code> will more than suffice, bumping support for doors up to thirty-two elements.
		I think I can abuse the node box and <code>wallmounted</code> mechanics to squeeze in half support for sixty-four more elements, though the need for that hasn&apos;t come yet.
		I&apos;ll want to keep that in mind from the get-go though, so as to get the correct node boxes built and the correct palette indexes assigned form the beginning.
	</p>
	<p>
		Trapdoors seem to store their hinge location, which is invisible, using the facing direction.
		If I instead store that via node metadata, I can multiply support for trapdoors by four.
		While I&apos;m at it, I could also fix the oddity that trapdoors have an open version and closed version also using node metatdata.
		The only reason such information needs to be known is so the door can make the opening or closing sound when it switches.
		Node metadata can more than handle that.
	</p>
	<p>
		Assuming I get the solution for the trapdoor problem coded, I thought the only remaining problem nodes were bones, the five gates, and water lilies.
		I personally think full rotational support for bones would be nice, and water lilies seem like they could use it too, if you wanted to stick them to the walls or ceiling for some reason.
		I don&apos;t think gates need to be flipped upside-down or sideways, but I could see builders complaining about not being able to, and it makes enough of a difference that I didn&apos;t want to risk it.
		I mean, it look stupid to have them upside-down or sideways, but maybe someone has a cool use for those facings that I don&apos;t know about.
		After thinking a bit though, I realised that all stairs are still problem nodes as well.
		I think I&apos;ve squeezed everything I can out of them, but they&apos;ll still only fully support sixteen elements and partly support eight more.
		That doesn&apos;t quite get then even to the twenty-six element threshold I want to start out with.
	</p>
	<p>
		I didn&apos;t write a single line of usable code today, but I think I made a lot of progress in planning.
		I can&apos;t say this modpack will likely be popular, but I think it&apos;ll be everything I&apos;m looking for.
	</p>
</section>
<section id="diet">
	<h2>Dietary intake</h2>
	<p>
		For breakfast, I had 106 grams of cereal and 360 grams of soy milk.
		For dinner, I made myself eat one of those nasty fajitas; this one weighing 426 grams.
		I&apos;d planned to have one for lunch too, but couldn&apos;t bring myself to do it.
		Instead, I snacked on 438 grams of pretzels and 438 grams of mixed juice.
	</p>
	<p>
		I guess tomorrow, I&apos;ll have to have three of those fajitas instead of the previously-planned two.
	</p>
</section>
<section id="voting">
	<h2>Not voting</h2>
	<p>
		Normally, I think it&apos;s important to vote.
		I haven&apos;t had time to even look at the ballot until today, which is when the ballots were due.
		So I took a look, figuring I&apos;d vote along party lines, as I don&apos;t know what candidates in this election stand for.
		It turns out we were voting on people to fill offices on the school board and community college.
		There are no parties and I don&apos;t know any of the candidates.
		And to top it off, several of the positions literally only have a single option.
		I think they let us vote as a formality to fill some law, which I agree really should happen, but my voting for the only candidate isn&apos;t going to make a difference.
	</p>
	<p>
		One measure was proposed as well.
		Again, not worth my vote.
		They want to issue bonds so they can destroy the county courthouse, which has become unsafe after sixty years of service, and build a new one.
		Here&apos;s the thing: bonds have interest.
		When the city takes out bonds, taxpayers pay more than face value when repaying.
		I agree that the courthouse should be replaced if it&apos;s become unsafe.
		Really, I do.
		But bonds are the wrong way to do it.
		We should be setting up a fund taxpayers pay into ahead of time, before such things come up.
		Then, when things such as courthouse demolition and construction need to happen, we can vote on whether to spend the fund on that and need to start paying back into the fund to replenish it.
		That way, we&apos;re not stuck paying bond interest.
		But people are short-sighted.
		They don&apos;t want to pay for something before it&apos;s needed.
		They&apos;d rather instead pay interest on something that&apos;s already happened.
		As such, we&apos;ll never have enough voters vote such a system into place.
		We&apos;ll be stuck doing things such as this the stupid and expensive way.
	</p>
</section>
<section id="drudgery">
	<h2>Drudgery</h2>
	<p>
		My discussion posts for the day:
	</p>
	<blockquote>
		<p>
			VirtualBox isn&apos;t an option for me, though other hypervisors are available.
			For example, I tend to use QEMU.
			However, a hypervisor doesn&apos;t really help the situation.
			I mentioned that in one course, I wasn&apos;t able to complete the assignments because we were required to use specific Windows applications.
			For a hypervisor (including VirtualBox) to help the situation, I&apos;d need to get a copy of Windows.
			I can&apos;t  afford to buy a copy of Windows that I&apos;ll use for one class, then throw away and never use again.
			Windows is expensive, not to mention that I outright refuse to give money to a company as terrible as Microsoft.
		</p>
		<p>
			As far as asking in the forum, I usually do that, though in this course, the professor said not to do that.
			If I needed serious help with this course (and thank Squiddy I don&apos;t), I wouldn&apos;t have that as an option.
			This isn&apos;t the first course in which that has happened, either, so using the forum, while usually an option, isn&apos;t always an option.
			It was by asking in the forum that I was able to get help with that one course though, as a student was kind enough to lend me remote access to their machine so I could complete the Windows-specific assignments.
		</p>
		<p>
			Perhaps I should email other students, though I tend to try not to bother people, as I don&apos;t know which ones would even want to hear from their fellow students.
			Perhaps that&apos;s my problem and I should work on that.
			Speaking of messaging though, the on-site messaging system hasn&apos;t worked for me since an overhaul of the system a few terms back.
			Anyone can feel free to email me if you like, but if you try to message me using the school&apos;s messaging system, I won&apos;t get the message.
			I won&apos;t even have any way to know you&apos;re trying to reach me.
		</p>
	</blockquote>
	<blockquote>
		<p>
			You briefly mention encryption being used to prevent data from being copied by unauthorised people or being destroyed.
			It&apos;s easy to see how it prevents unauthorised copying, but could you elaborate on how it prevents data from being destroyed?
			I couldn&apos;t find that information even after reading a dozen or so articles to find a good one to write about.
		</p>
		<p>
			I&apos;d also like to mention that knowledge of the cypher used is not itself the worst thing that could happen.
			When cyphers are publicly known, they get audited more and their flaws exposed so new, better cyphers can be developed.
			Having the cyphers known is a very good thing.
			Rather, the problem is when people know the <strong>*encryption keys*</strong>.
			It&apos;s fine to know what cypher was used to encrypt a given piece of data, and it&apos;s actually my understanding that encrypted data often tends to be marked in some way with metadata that outright tells what cypher was used.
			It&apos;s only the keys that we&apos;ve got to keep hidden.
			You even mentioned a specific cloud provider and how they tell you what cypher they use to encrypt the data.
			It&apos;s one of their bragging points.
			They tell you what cypher they use, so if you know your cyphers, you know it&apos;s one of the harder-to-break ones.
		</p>
	</blockquote>
</section>
<section id="religion">
	<h2>Religious study</h2>
	<p>
		The missionaries wrote today, asking if we were still on for this week.
		But their email was titled &quot;tomorrow&quot;.
		I don&apos;t know when they&apos;re coming over, but I hope it actually <strong>*is*</strong> tomorrow.
		It&apos;d mean they&apos;re not coming over the next day, which is already going to be a very busy day for me.
		I could use the extra time that day.
	</p>
	<p>
		But also, why are they still coming?
		How did I not scare them away by calling their doctrine evil, calling their gods evil, even calling <strong>*them*</strong> evil, and then not showing up at church on Sunday?
		I mean, I was polite about it, but I did say that if they actually believed this homophobic trash, they were evil.
		And at least one of the two does believe it.
		I think they both do, but the other didn&apos;t outright say anything to that effect.
	</p>
</section>
END
);
